package cn.xiaobai.captcha.enums;

import java.util.Objects;

/**
 * @author yangdaji
 * @version 1.0
 * @Description: 简单算术运算符-> 数学运算符
 * @date 22-6-12 上午 12:10
 */
public enum OperatorEnum {

//    ADD("+", "加", "\\+"),
    SUB("-", "减", "\\-"),
    MUL("x", "乘", "\\*"),
    DIV("÷", "除", "\\/");

    private final String alias;
    private final String desc;
    private final String operator;

    OperatorEnum(String alias, String desc, String operator) {
        this.alias = alias;
        this.desc = desc;
        this.operator = operator;
    }

    public String getAlias() {
        return alias;
    }

    public String getDesc() {
        return desc;
    }

    public String getOperator() {
        return operator;
    }

    public static String getOperator(String alias) {
        OperatorEnum[] values = OperatorEnum.values();
        for (OperatorEnum value : values) {
            if (Objects.equals(value.getAlias(), alias)) {
                return value.getOperator();
            }
        }
        throw new IllegalStateException("没有匹配到相关类型");
    }
}
